package com.punai.gk.controller;

import com.punai.common.annotation.Log;
import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.core.domain.TreeBo;
import com.punai.common.core.page.TableDataInfo;
import com.punai.common.enums.BusinessType;
import com.punai.gk.domain.GkLinkFee;
import com.punai.gk.domain.vo.GkLinkFeeVo;
import com.punai.gk.service.IGkLinkFeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 归口关联费用项Controller
 * 
 * @author zxw_
 * @date 2023-01-06
 */
@RestController
@RequestMapping("/gk/linkFee")
public class GkLinkFeeController extends BaseController
{
    @Autowired
    private IGkLinkFeeService gkLinkFeeService;

    /**
     * 查询归口关联费用项列表
     */
    @PreAuthorize("@ss.hasPermi('gk:linkFee:list')")
    @GetMapping("/list")
    public TableDataInfo list(GkLinkFee gkLinkFee)
    {
        startPage();
        List<GkLinkFee> list = gkLinkFeeService.selectGkLinkFeeList(gkLinkFee);
        return getDataTable(list);
    }

    @GetMapping("/getCurrNewFeeChapter/{type}")
    public List<TreeBo> getCurrNewFeeChapter(String type) {
        return gkLinkFeeService.getCurrNewFeeChapter(type);
    }

    @GetMapping("/getCurrNewFeeList")
    public TableDataInfo getCurrNewFeeList(GkLinkFeeVo vo) {
        return gkLinkFeeService.getLastPubFee(vo);
    }


    /**
     * 获取归口关联费用项详细信息
     */
    @PreAuthorize("@ss.hasPermi('gk:linkFee:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(gkLinkFeeService.selectGkLinkFeeById(id));
    }

    /**
     * 新增归口关联费用项
     */
    @PreAuthorize("@ss.hasPermi('gk:linkFee:add')")
    @Log(title = "归口关联费用项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GkLinkFee gkLinkFee)
    {
        return toAjax(gkLinkFeeService.insertGkLinkFee(gkLinkFee));
    }

    /**
     * 修改归口关联费用项
     */
    @PreAuthorize("@ss.hasPermi('gk:linkFee:edit')")
    @Log(title = "归口关联费用项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GkLinkFee gkLinkFee)
    {
        return toAjax(gkLinkFeeService.updateGkLinkFee(gkLinkFee));
    }

    /**
     * 删除归口关联费用项
     */
    @PreAuthorize("@ss.hasPermi('gk:linkFee:remove')")
    @Log(title = "归口关联费用项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gkLinkFeeService.deleteGkLinkFeeByIds(ids));
    }
}
